﻿package physic
{
	import flash.display.DisplayObject;
	import flash.geom.Point;
	import bipede.membres.Squelette;
	
	public class SoftBody
	{
		public var display:DisplayObject;
		public var masse:Number = 1;
		public var acceleration:Point = new Point(0,10);
		public var vitesse:Point = new Point(0, 0);
		public var reactions:Vector.<Reaction> = new Vector.<Reaction>();
		
		public function SoftBody( _display:DisplayObject )
		{
			display = _display;
		}
		public function removeAllReactions():void
		{
			reactions = new Vector.<Reaction>();
		}		
		public function addReaction( r:Reaction ):void
		{
			if ( reactions.indexOf( r ) == -1 ) reactions.push( r );
		}
		public function get centre():Point
		{
			return display.localToGlobal( (display as Squelette).tree.rootJoint.position );
		}		
		public function removeReaction( r:Reaction ):void
		{
			reactions.splice( reactions.indexOf( r ), 1 );
		}				
		public function toString():String
		{
			return "SoftBody : " + display.name + ", " + acceleration + ", " + vitesse;
		}	
	}	
}